import 'package:fish_redux/fish_redux.dart';

import 'action.dart';
import 'state.dart';

Reducer<LoginPageState> buildReducer() {
  return asReducer(
    <Object, Reducer<LoginPageState>>{
      LoginPageAction.init: _init,
    },
  );
}

LoginPageState _init(LoginPageState state, Action action) {
  final LoginPageState newState = state.clone();
  final LoginPageState payload = action.payload ?? LoginPageState();

  newState.formKey = payload.formKey;
  newState.usernameController = payload.usernameController;
  newState.passwordController = payload.passwordController;

  return newState;
}
